<template>
    <el-form class="content" :model="itemModel" ref="itemModel" label-position='top' label-width="120px">
        <el-form-item label="商品展示区：" prop="coverPhotos">
            <el-row>
                <!-- <el-col><uploadList ref='coverPhotoList' :fileList='itemModel.coverPhotoList' :fileSize='10' listType='picture'></uploadList></el-col> -->
                <el-col><uploadList scene="image" ref='coverPhotoList' :fileList='itemModel.coverPhotoList' :fileSize='10' listType='picture'></uploadList></el-col>
            </el-row>
        </el-form-item>
        <el-form-item label="商品详情区：" prop="detailPhotos">
            <el-row style="width: 375px;">
                <Editor v-model="itemModel.detailPhotosRichText" :minHeight="600" />
            </el-row>
        </el-form-item>
    </el-form>
</template>
<script>
import uploadList from '@/components/jcupload/list'
import Editor from '@/components/Editor';
export default {
    components:{ uploadList, Editor },
    props:{
        itemModel:{
            type: Object,
            default: {}
        }
    },
    data() {
        return{
            loading: false,
        }
    },
    created(){
    },
     methods: {
        //子组件校验，传递到父组件
        validateForm () {
            console.log('itemModel2', this.itemModel)
            let flag = false
            this.$refs['itemModel'].validate(valid => {
                if (valid) {
                    var coverPhotos = this.$refs.coverPhotoList.handleFileList()
                    // this.itemModel.coverPhotos = '临时为空'
                    console.log('coverPhotos', coverPhotos)
                    if(coverPhotos.length <= 0){
                        this.$message.error('至少选择一张商品展示图');
                    }else{
                        this.itemModel.coverPhotos = JSON.stringify(coverPhotos)
                        flag = true
                    }
                } else {
                    flag = false
                }
            })
            console.log('flag', flag)
            return flag
        },
    },
}
</script>
<style lang='scss' scoped>

</style>